const fs = require("fs");
const path = require('path');

const res = fs.readFileSync(path.join(__dirname, "./info.json"), "utf-8");
const JSarr = JSON.parse(res)

const getRandomInt = (max) => Math.floor(Math.random() * max);

const randomNum = getRandomInt(JSarr.length)

console.log(randomNum);

JSarr.forEach(item => {
  if (item.id == randomNum) {
    item.count++
  }
})
fs.writeFileSync('./info.json', JSON.stringify(JSarr))